package com.fowo.api.sms.controller;

import com.fowo.api.common.model.R;
import com.fowo.api.sms.model.SendPhoneCode;
import com.fowo.api.sms.service.VerificationCodeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Tag(name = "短信")
@RestController
@RequestMapping("/api/sms")
public class SmsController {
    @Resource
    private VerificationCodeService verificationCodeService;

    @Operation(summary = "发送短信验证码")
    @PostMapping("send")
    public R send(@RequestBody SendPhoneCode sendPhoneCode) {
        return R.run(() -> verificationCodeService.sendCode(sendPhoneCode.getPhone()));
    }

}
